package com.coderdream.chapter11.composite.a1;

public abstract class Entry {
	
	protected Entry parent;
	

	public Entry add(Entry entry) throws FileTreatmentException {
		throw new FileTreatmentException();
	}
	
	public void printList() {
		this.printList("");
	}
	
	// 在前面加上 prefix 后輸出總覽
	protected abstract void printList(String prefix);

	// 字符串輸出格式
	public String toString() {
		return this.getName() + " (" + this.getSize() + ")";
	}

	public String getFullName() {
		StringBuffer fullname = new StringBuffer();
		Entry entry = this;
		
		do {
			fullname.insert(0, "/" + entry.getName());
			entry = entry.parent;
		} while (entry != null);
		
		return fullname.toString();
	}
	
	public abstract int getSize();

	public abstract String getName();
}
